/**
 * The ISlot interface defines the basic properties of a
 * listener associated with a Signal.
 *
 * @author Joa Ebert
 * @author Robert Penner
 */
package org.osflash.signals;

interface ISlot {
	var listener(getListener, setListener) : Dynamic;
	var params(getParams, setParams) : Array<Dynamic>;
	var once(getOnce, never) : Bool;
	var priority(getPriority, never) : Int;
	var enabled(getEnabled, setEnabled) : Bool;

	/**
	 * The listener associated with this slot.
	 */
	function getListener() : Dynamic;
	function setListener(value : Dynamic) : Dynamic;
	/**
	 * Allows the ISlot to inject parameters when dispatching. The params will be at 
	 * the tail of the arguments and the ISignal arguments will be at the head.
	 * 
	 * var signal:ISignal = new Signal(String);
	 * signal.add(handler).params = [42];
	 * signal.dispatch('The Answer');
	 * function handler(name:String, num:int):void{}
	 */
	function getParams() : Array<Dynamic>;
	function setParams(value : Array<Dynamic>) : Array<Dynamic>;
	/**
	 * Whether this slot is automatically removed after it has been used once.
	 */
	function getOnce() : Bool;
	/**
	 * The priority of this slot should be given in the execution order.
	 * An IPrioritySignal will call higher numbers before lower ones.
	 * Defaults to 0.
	 */
	function getPriority() : Int;
	/**
	 * Whether the listener is called on execution. Defaults to true.
	 */
	function getEnabled() : Bool;
	function setEnabled(value : Bool) : Bool;
	/**
	 * Executes a listener without arguments.
	 * Existing <code>params</code> are appended before the listener is called.
	 */
	function execute0() : Void;
	/**
	 * Dispatches one argument to a listener.
	 * Existing <code>params</code> are appended before the listener is called.
	 * @param value The argument for the listener.
	 */
	function execute1(value : Dynamic) : Void;
	/**
	 * Executes a listener of arity <code>n</code> where <code>n</code> is
	 * <code>valueObjects.length</code>.
	 * Existing <code>params</code> are appended before the listener is called.
	 * @param valueObjects The array of arguments to be applied to the listener.
	 */
	function execute(valueObjects : Array<Dynamic>) : Void;
	/**
	 * Removes the slot from its signal.
	 */
	function remove() : Void;
}

